package path

import (
	"fmt"
	"os"

	"github.com/cockroachdb/errors"
)

func FindFileOnClassPath(fileName string, exceptionOnNotFound bool) (*os.File, error) {
	f, err := os.Open(fileName)
	if err != nil && exceptionOnNotFound {
		return nil, errors.Wrap(err, fmt.Sprintf("unable to find file[%s] on classpath", fileName))
	}

	return f, err
}
